/* Sokoban
 * HIT3243
 * Authors: Mike Blackney, Ben Ingarfield, Kurniawan
 */

#pragma once

#include <list>
#include <memory>
#include "pawn.h"

/* struct AutoPawn
 *
 * Keeps an auto_ptr of a pawn, for easy cleanup, and
 * helps us sort pawns more easily by redirecting op <
 *
 */

struct AutoPawn {

	// Need mutable because the copy constructor
	// must have a const Pawn, yet it changes the
	// auto_ptr on assign!
	mutable std::auto_ptr<Pawn> pawn;

	AutoPawn( ); // Need default to be in a std::list
	AutoPawn( Pawn& );
	AutoPawn( const AutoPawn& ); // Need copy to be in list

	Pawn* operator ->( ) const;

	bool operator <( const AutoPawn &other ) const;
	bool operator ==( const AutoPawn &other ) const;
};

/* class PawnList
 *
 * Retains a list of all the pawns on a level.
 * Responsible for sorting the list, for rendering
 * the pawns and calling their update methods.
 * Also performs collision detection if requested.
 */

class PawnList {
public:
	void Add( Pawn& );
	void Clear( );

	void Update( double fTime, float fElapsedTime );
	void Render3D( IDirect3DDevice9 *pd3dDevice, double fTime, float fElapsedTime );

private:

	std::list<AutoPawn> pawns;
};
